<template>
    <view class="goods">
        <view class="list ph-32 pt-32 mb-20" v-for="(item, index) in list" :key="index" @click='toDetail(item)'>
            <!-- <view class="fs-28 fw-600 text-color4 ph-8">店铺一</view> v-for="(item, index1) in 2" :key="index1"-->
            <view class="f ai-c jc-s-b pv-32" >
                <image :src="item.picUrl" class="w-160 h-160 b-12 mr-32"></image>
                <view class="f ai-c js-c-b f1">
                    <view class="f fd-c f1">
                        <view class="fs-32 fw-600 text-color4 text-ellipsis-1">{{item.spuName}}</view>
                        <view class="mt-12 fs-36 fw-600 text-color8">¥{{item.price}}</view>
                        <!-- <view class="mt-17 fs-24 text-color2">运费：¥21.00</view> -->
                    </view>
                    <image src="http://cwht.ricecs.cn/app/index/star-select.png" class="w-32 h-32 ml-32" @click='fav(item)'></image>
                </view>
            </view>
        </view>
    </view>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import { favoriteLists } from '@/services/api/mine/index';
import { favoriteDelete } from '@/services/api/shop/collect';
const list = ref<any[]>([]);
const listQuery = ref({
    pageNo: 1,
    pageSize: 10,
		collectionType:1
});
getContentPage();
async function getContentPage() {
	    const { data } = await favoriteLists(listQuery.value);
	    if (data.list.length > 0) {
	        data.list.forEach((item: any, index: number) => {
						let list2=item.picUrl.split(',')
						if(list2.length>0){
							item.picUrl=list2[0]
						}
						
				list.value.push(item);
	        });
	    }
	}	
async function fav(item:any) {
	 await favoriteDelete({ spuId: item.spuId });
	   listQuery.value.pageNo = 1
	   getContentPage();
	}	
	function toDetail(item: any){
		uni.navigateTo({
		    url: `/pages_shop/productDetails/index?id=${item.spuId}`,
		});
	};
	
</script>
<style lang="scss" scoped>
.goods {
    background: #f5f5f5;
    min-height: 100vh;
    .list {
        background: #fff;
    }
}
</style>
